home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 4_0 / MORSE_CD / SHOWINIT.C < prev   
Text File  |  1989-11-11  |  2KB  |  87 lines

  1. /*
  2.     Simple INIT notification routine in THINK C 3.02
  3. */
  4.  
  5. #define CKSM(i)                \
  6.     asm {                    \
  7.         ROL #1,i            \
  8.         EOR #0x1021,i        \
  9.     }
  10.  
  11. typedef struct QuickDraw {        /* QuickDraw globals */
  12.     char private[76];
  13.     long randSeed;
  14.     BitMap screenBits;
  15.     Cursor arrow;
  16.     Pattern dkGray;
  17.     Pattern ltGray;
  18.     Pattern gray;
  19.     Pattern black;
  20.     Pattern white;
  21.     GrafPtr thePort;
  22. } QuickDraw;
  23.  
  24. extern short myH : 0x92C;        /* CurApName + 28 */
  25. extern short myCheck: 0x92E;    /* CurApName + 30 */
  26. extern long oldSig: 0xA78;        /* ApplScratch */
  27. extern short oldH: 0xA7E;        /* ApplScratch + 6 */
  28.  
  29. void ShowINIT(iconID)
  30. register short iconID;            /* ICN# resource ID */
  31. {
  32.     register Handle h;
  33.     register short i;
  34.     Rect srcRect, destRect;
  35.     BitMap myBitMap;
  36.     GrafPort myPort;
  37.     struct {
  38.         QuickDraw qdGlobals;
  39.         Ptr localA5;
  40.     } qd;
  41.  
  42.     asm {
  43.         MOVE.L A5,-(SP)
  44.         LEA.L qd.localA5,A5
  45.     }
  46.     if (!(h = GetResource('ICN#', iconID)))
  47.         goto out;    /* Error */
  48.     InitGraf(&qd.qdGlobals.thePort);
  49.     OpenPort(&myPort);
  50.  
  51.     i = myH;
  52.     CKSM(i);
  53.     if (i == myCheck)
  54.         i = myH;
  55.     else
  56.         if (oldSig == 'Paul')
  57.             i = oldH;
  58.         else
  59.             i = 8;
  60.     destRect.bottom = myPort.portRect.bottom - 8;
  61.     destRect.left = myPort.portRect.left + i;
  62.     destRect.top = destRect.bottom - 32;
  63.     destRect.right = destRect.left + 32;
  64.     i += 40;
  65.     myH = i;
  66.     CKSM(i);
  67.     myCheck = i;
  68.  
  69.     HLock(h);
  70.     srcRect.top = srcRect.left = 0;
  71.     srcRect.bottom = srcRect.right = 32;
  72.     myBitMap.rowBytes = 4;
  73.     myBitMap.bounds = srcRect;
  74.     myBitMap.baseAddr = *h + 128;    /* Skip to mask */
  75.     CopyBits(&myBitMap, &myPort.portBits, &srcRect, &destRect, srcBic, 0L);
  76.     myBitMap.baseAddr = *h;            /* Now draw icon */
  77.     CopyBits(&myBitMap, &myPort.portBits, &srcRect, &destRect, srcOr, 0L);
  78.     HUnlock(h);
  79.     ReleaseResource(h);
  80.  
  81.     ClosePort(&myPort);
  82. out:
  83.     asm {
  84.         MOVE.L (SP)+,A5
  85.     }
  86. }
  87.